import { createApp } from "vue";
import "./registerServiceWorker";
import { routes } from "./router";
import { createRouter, createWebHistory } from "vue-router";
import App from "./App.vue";
// createApp(App).use(store).use(router).mount("#app");
let history;
let router;
let app;
const windowNew: any = window;

const render = (props: any = {}) => {
  history = createWebHistory(
    windowNew.__POWERED_BY_QIANKUN__ ? "/m-vue3" : "/"
  );
  router = createRouter({
    history,
    routes,
  });
  app = createApp(App);
  const { container } = props;
  app.use(router).mount(container ? container.querySelector("#app") : "#app");
};
if (!windowNew.__POWERED_BY_QIANKUN__ as any) {
  render();
}
export const bootstrap = async () => {
  console.log("vue3启动");
};
export const mount = async (props: any) => {
  console.log("vue3挂载");
  render(props);
};
export const unmount = async () => {
  history = null;
  app = null;
  router = null;
  console.log("vue3卸载");
};
